﻿using System;
using Loki.Utils;

namespace Loki.UI
{
    public abstract class ViewModelBase : TrackedObject, IDisposable
    {
        #region Disposable

        /// <summary>
        /// Releases all resources used by an instance of the <see cref="ViewModelBase" /> class.
        /// </summary>
        /// <remarks>
        /// This method calls the virtual <see cref="Dispose(bool)" /> method, passing in
        /// <strong>true</strong>, and then suppresses finalization of the instance.
        /// </remarks>
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        ~ViewModelBase()
        {
            Dispose(false);
        }

        /// <summary>
        /// Releases the unmanaged resources used by an instance of the <see cref="ViewModelBase" />
        /// class and optionally releases the managed resources.
        /// </summary>
        /// <param name="P_Disposing"><strong>true</strong> to release both managed and unmanaged
        /// resources; <strong>false</strong> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool P_Disposing)
        {
        }

        #endregion Disposable
    }
}